$(function(){
    berserker.addView({
        name:'mtbd',
        tpl:'tpl_mtbd',
        dataURL:'/api/mtbd.json',
        beforeRender:function(host){
            var chartEvent={};
            chartEvent['mtbd-chart2']={
                plotOptions: {
                    pie: {
                        allowPointSelect: true,cursor: 'pointer',
                        showInLegend:true,
                        dataLabels: {
                            enabled: false,
                            color: '#000000',
                            connectorColor: '#000000',
                            formatter: function() {
                                return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
                            }
                        }
                    }
                }
            }
            host.data('chartEvent',chartEvent);
        },
        done:function(host,data){
            //绑定tab view
            //$(".tabview > ul",host).tabs(".tabview > .tabContent");
            //跑马灯
            $('.slidetabs').jcarousel({
                auto: 2,
                wrap: 'last',
                scroll:1,
                animation:'slow'
            });

            $(".tabview > ul li",host).click(function(){
                var tab = $('.tabContent:eq('+this.getAttribute('data-role')+')',host);
                 if(tab){
                    var cloud =  $('.tagCloud',tab);
                    if(cloud){
                        setTimeout(function(){
                            if(cloud.attr('data-key')){
                                cloud.jQCloud(data['tagCloud'][cloud.attr('data-key')]);
                                cloud.click(function(evt){
                                    var target = evt.target;
                                    if(target && target.tagName == 'SPAN'){
                                        showRight(this.getAttribute('data-url'),{key:target.innerHTML});
                                    }
                                })
                                cloud.attr('data-key',null)
                            }
                        },200)
                    }
                }
            })
        }
    })
})
